# # 类继承练习：人力系统
# # - 员工分为两类：全职员工 FullTimeEmployee、兼职员工 PartTimeEmployee。
# # - 全职和兼职都有"姓名 name"、"工号 id"属性，
# #   都具备"打印信息 print_info"（打印姓名、工号）方法。
# # - 全职有"月薪 monthly_salary"属性，
# #   兼职有"日薪 daily_salary"属性、"每月工作天数 work_days"的属性。
# # - 全职和兼职都有"计算月薪 calculate_monthly_pay"的方法，但具体计算过程不一样。
#
# class Employee:
#     def __init__(self, name, id):
#         self.name = name
#         self.id = id
#
#     def print_info(self):
#         print(f"员工名字：{self.name}，工号：{self.id}")
#
# class FullTimeEmployee(Employee):
#     def __init__(self, name, id, monthly_salary):
#         super().__init__(name, id)
#         self.monthly_salary = monthly_salary
#
#     def calculate_monthly_pay(self):
#         return self.monthly_salary
#
# class PartTimeEmployee(Employee):
#     def __init__(self, name, id, daily_salary, work_days):
#         super().__init__(name, id)
#         self.daily_salary = daily_salary
#         self.work_days = work_days
#
#     def calculate_monthly_pay(self):
#         return self.daily_salary * self.work_days
#
# zhangsan = FullTimeEmployee("张三", "1001", 6000)
# lisi = PartTimeEmployee("李四", "1002", 230, 15)
# zhangsan.print_info()
# lisi.print_info()
# print(zhangsan.calculate_monthly_pay())
# print(lisi.calculate_monthly_pay())

class Employee:
    def __init__(self, name, emp_id):
        self.name = name
        self.emp_id = emp_id
        self.projects = []

    def print_info(self):
        print(f"员工：{self.name}，工号：{self.emp_id}")

    def assign_project(self, project):
        self.projects.append(project)
        print(f"{self.name}被分配到项目：{project}")


class ProjectEmployee(Employee):
    def __init__(self, name, emp_id, hourly_rate):
        super().__init__(name, emp_id)
        self.hourly_rate = hourly_rate
        self.project_hours = {}

    def log_hours(self, project, hours):
        if project in self.project_hours:
            self.project_hours[project] += hours
        else:
            self.project_hours[project] = hours

    def calculate_monthly_pay(self):
        total_hours = sum(self.project_hours.values())
        return total_hours * self.hourly_rate

    def print_project_report(self):
        print(f"{self.name}的项目工时报告：")
        for project, hours in self.project_hours.items():
            print(f"  项目{project}：{hours}小时")
        print(f"  总工时：{sum(self.project_hours.values())}小时")


# 使用示例
project_emp = ProjectEmployee("钱七", "1005", 80)
project_emp.assign_project("电商平台")
project_emp.assign_project("移动APP")

project_emp.log_hours("电商平台", 40)
project_emp.log_hours("移动APP", 30)
project_emp.log_hours("电商平台", 20)

project_emp.print_info()
project_emp.print_project_report()
print(f"本月工资：{project_emp.calculate_monthly_pay()}元")